







[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Finds the last item in a collection that satisfies the condition
defined by predicate.
Namespace: Wintellect.PowerCollections
Assembly:
PowerCollections (in PowerCollections.dll)
Syntax
C# |
---|
public static T FindLastWhere<T>( IEnumerable<T> collection, Predicate<T> predicate ) |
Visual Basic (Declaration) |
---|
Public Shared Function FindLastWhere(Of T) ( _ collection As IEnumerable(Of T), _ predicate As Predicate(Of T) _ ) As T |
Visual C++ |
---|
public: generic<typename T> static T FindLastWhere ( IEnumerable<T>^ collection, Predicate<T>^ predicate ) |
Parameters
- collection
- IEnumerable<(Of <T>)>
The collection to search.
- predicate
- Predicate<(Of <T>)>
A delegate that defined the condition to check for.
Return Value
The last item in the collection that matches the condition, or the default value for T (0 or null) if no item that matches the condition is found.
Type Parameters
- T
Remarks
If the collection implements IList<T>, then the list is scanned in reverse until a matching item is found. Otherwise, the entire collection is iterated in the forward direction.
If the default value for T could be present in the collection, and would be matched by the predicate, then this method is inappropriate, because you cannot disguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere.